package com.example.weight.wormHandle.cultivate;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.DatePickerDialog;
import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

import com.android.volley.AuthFailureError;
import com.android.volley.DefaultRetryPolicy;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
import com.example.weight.R;
import com.example.weight.arrayAdapter.MyAdapter;
import com.example.weight.config.Config;
import com.example.weight.greenSeasons.SolidLiquid.SolidLiquidWeekMaintenanceActivity;
import com.example.weight.util.WeightActivity;
import com.hjq.bar.OnTitleBarListener;
import com.hjq.bar.TitleBar;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;

public class SmallWormBreedingOutcoming extends AppCompatActivity{

    private String batchStr, groupStr, boxNumStr, primaryKeyStr, endIncubationDateStr, activeButton, idStr, factory;
    private Double boxWeight = 0.0, backBoxAndMaterialWeight = 0.0, middleWormAndWormDrossWeight = 0.0, copies = 0.0, kgPerCopy = 0.0, gPerCopy = 0.0;
    private Date endIncubationDate, endBreedingDate;
    private EditText et_remarks,et_box_weight, et_copies, et_kg_per_copy, et_g_per_copy, et_after_small_weight, et_first_box;
    private TextView tv_end_date;
    private String stop_reason;//确定终止时候的原因
    private int stop_flag=0;//标记：终止培育是否选择
    private List<String> primaryKeyList, idList, weightList;
    private Spinner sp_primary_key;
    private Calendar calendar = Calendar.getInstance(Locale.CHINA);
    @SuppressLint("SimpleDateFormat")
    private SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
    final DecimalFormat formater = new DecimalFormat();


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_small_worm_breeding_outcoming);

        Intent previousIntent = getIntent();
        factory = previousIntent.getStringExtra("factory");

        RadioGroup group = findViewById(R.id.small_bug_group_button);
        //所有正常异常按钮
        RadioButton normal = findViewById(R.id.normal_button);
        RadioButton abnormal = findViewById(R.id.abnormal_button);

        formater.setMaximumFractionDigits(4);
        formater.setGroupingSize(0);
        formater.setRoundingMode(RoundingMode.FLOOR);

        tv_end_date = findViewById(R.id.tv_end_date);
//        et_box_weight = findViewById(R.id.et_box_weight);
        et_remarks =findViewById(R.id.et_remarks);
//        et_copies = findViewById(R.id.et_copies);
//        et_kg_per_copy = findViewById(R.id.et_kg_per_copy);
//        et_g_per_copy = findViewById(R.id.et_g_per_copy);
//        et_after_small_weight = findViewById(R.id.et_after_small_weight);
//        et_first_box = findViewById(R.id.et_first_box);
        sp_primary_key = findViewById(R.id.sp_primary_key);
        primaryKeyList = new ArrayList<>();
        idList = new ArrayList<>();
//        weightList = new ArrayList<>();
//        et_kg_per_copy.setFocusable(false);
//        et_g_per_copy.setFocusable(false);

//        endIncubationDate = new Date();
//        calendar.setTime(endIncubationDate);
//        calendar.add(Calendar.DATE, 2);
//        endBreedingDate = calendar.getTime();
        tv_end_date.setText(simpleDateFormat.format(new Date()));
        tv_end_date.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showDatePickerDialog(SmallWormBreedingOutcoming.this, 2, tv_end_date, calendar);
            }
        });
        //份数默认46
//        et_copies.setText("46");
//        et_first_box.setText("PY");

        getPrimaryKeyRecord();

        TitleBar titleBar = findViewById(R.id.titleBar);
        titleBar.setOnTitleBarListener(new OnTitleBarListener() {
            @Override
            public void onLeftClick(View v) {
                finish();
            }

            @Override
            public void onTitleClick(View v) {}

            @Override
            public void onRightClick(View v) {}
        });

        normal.setOnClickListener(v -> {
            if (normal.isChecked()) {
                saveNormal(normal, abnormal, group);
            }
        });
        abnormal.setOnClickListener(v -> {
            if (abnormal.isChecked()) {
                saveAbnormal(normal, abnormal, group);
            }
        });

//        et_after_small_weight.addTextChangedListener(new TextWatcher() {
//            @Override
//            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
//
//            }
//
//            @Override
//            public void onTextChanged(CharSequence s, int start, int before, int count) {
//                if(et_box_weight.getText().toString().equals("")){
//                    return;
//                }
//                if(Double.parseDouble(et_box_weight.getText().toString()) == 0){
//                    Toast.makeText(SmallWormBreedingOutcoming.this, "小虫培育盒重获取异常", Toast.LENGTH_SHORT).show();
//                }
//            }

//            @Override
//            public void afterTextChanged(Editable s) {
////                if(et_box_weight.getText().toString().equals("") || et_copies.getText().toString().equals("") ||
////                        et_copies.getText().toString().equals("0") || et_after_small_weight.getText().toString().equals("")){
////                    return;
////                }
//                if(et_box_weight.getText().toString().equals("") || et_after_small_weight.getText().toString().equals("")){
//                    return;
//                }
////                middleWormAndWormDrossWeight = Double.parseDouble(et_after_small_weight.getText().toString())-Double.parseDouble(et_box_weight.getText().toString());
//
////                kgPerCopy = middleWormAndWormDrossWeight/Double.parseDouble(et_copies.getText().toString());
////                gPerCopy = kgPerCopy*1000;
//
////                et_kg_per_copy.setText(formater.format(kgPerCopy));
////                et_g_per_copy.setText(formater.format(Double.parseDouble(et_kg_per_copy.getText().toString())*1000));
////                et_after_small_weight.setText(formater.format(kgPerCopy+Integer.parseInt(et_box_weight.getText().toString())));
//            }
//        });
//
//        et_box_weight.addTextChangedListener(new TextWatcher() {
//            @Override
//            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
//
//            }
//
//            @Override
//            public void onTextChanged(CharSequence s, int start, int before, int count) {
//                if(Double.parseDouble(et_box_weight.getText().toString()) == 0){
//                    Toast.makeText(SmallWormBreedingOutcoming.this, "小虫培育盒重获取异常", Toast.LENGTH_SHORT).show();
//                }
//            }
//
//            @Override
//            public void afterTextChanged(Editable s) {
////                if(et_box_weight.getText().toString().equals("") || et_copies.getText().toString().equals("") ||
////                        et_copies.getText().toString().equals("0") || et_after_small_weight.getText().toString().equals("")){
////                    return;
////                }
////                middleWormAndWormDrossWeight = Double.parseDouble(et_after_small_weight.getText().toString())-Double.parseDouble(et_box_weight.getText().toString());
//
//                if(et_box_weight.getText().toString().equals("") || et_after_small_weight.getText().toString().equals("")){
//                    return;
//                }
//
////                kgPerCopy = middleWormAndWormDrossWeight/Double.parseDouble(et_copies.getText().toString());
////                gPerCopy = kgPerCopy*1000;
//
////                et_kg_per_copy.setText(formater.format(kgPerCopy));
////                et_g_per_copy.setText(formater.format(Double.parseDouble(et_kg_per_copy.getText().toString())*1000));
////                et_after_small_weight.setText(formater.format(kgPerCopy+Integer.parseInt(et_box_weight.getText().toString())));
//            }
//        });

//        et_copies.addTextChangedListener(new TextWatcher() {
//            @Override
//            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
//
//            }
//
//            @Override
//            public void onTextChanged(CharSequence s, int start, int before, int count) {
//                if(Double.parseDouble(et_box_weight.getText().toString()) == 0){
//                    Toast.makeText(SmallWormBreedingOutcoming.this, "小虫培育盒重获取异常", Toast.LENGTH_SHORT).show();
//                }
//            }
//
//            @SuppressLint("SetTextI18n")
//            @Override
//            public void afterTextChanged(Editable s) {
//                if(et_box_weight.getText().toString().equals("") || et_copies.getText().toString().equals("") ||
//                        et_copies.getText().toString().equals("0") || et_after_small_weight.getText().toString().equals("")){
//                    return;
//                }
//                middleWormAndWormDrossWeight = Double.parseDouble(et_after_small_weight.getText().toString())-Double.parseDouble(et_box_weight.getText().toString());
//
//                kgPerCopy = middleWormAndWormDrossWeight/Double.parseDouble(et_copies.getText().toString());
//                gPerCopy = kgPerCopy*1000;
//
//                et_kg_per_copy.setText(formater.format(kgPerCopy));
//                et_g_per_copy.setText(formater.format(Double.parseDouble(et_kg_per_copy.getText().toString())*1000));
//                et_after_small_weight.setText(formater.format(kgPerCopy+Integer.parseInt(et_box_weight.getText().toString())));
//            }
//        });

//        et_box_weight.addTextChangedListener(new TextWatcher() {
//            @Override
//            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
//
//            }
//
//            @Override
//            public void onTextChanged(CharSequence s, int start, int before, int count) {
//
//            }
//
//            @SuppressLint("SetTextI18n")
//            @Override
//            public void afterTextChanged(Editable s) {
//                if(et_box_weight.getText().toString().equals("") || et_copies.getText().toString().equals("") ||
//                        et_copies.getText().toString().equals("0") || et_after_small_weight.getText().toString().equals("")){
//                    return;
//                }
//                middleWormAndWormDrossWeight = Double.parseDouble(et_after_small_weight.getText().toString())-Double.parseDouble(et_box_weight.getText().toString());
//
//                kgPerCopy = middleWormAndWormDrossWeight/Double.parseDouble(et_copies.getText().toString());
//                gPerCopy = kgPerCopy*1000;
//
//                et_kg_per_copy.setText(formater.format(kgPerCopy));
//                et_g_per_copy.setText(formater.format(Double.parseDouble(et_kg_per_copy.getText().toString())*1000));
//                et_after_small_weight.setText(formater.format(kgPerCopy+Integer.parseInt(et_box_weight.getText().toString())));
//            }
//        });

        tv_end_date.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showDatePickerDialog(SmallWormBreedingOutcoming.this, 2, tv_end_date, calendar);
            }
        });
    }

    public void submit(View view){
        if(primaryKeyStr == null){
            Toast.makeText(this, "请选择批次-组别-微虫培育盒号-小虫培育盒号", Toast.LENGTH_SHORT).show();
            return;
        }
        if(tv_end_date.getText().toString().equals("")){
            Toast.makeText(this, "请填写小虫培育结束日期", Toast.LENGTH_SHORT).show();
            return;
        }
        if(stop_flag==0){
            Toast.makeText(this, "请选择是否终止培育", Toast.LENGTH_SHORT).show();
            return;
        }
//        if(et_remarks.getText().toString().equals("")){
//            Toast.makeText(this, "请填写备注", Toast.LENGTH_SHORT).show();
//            return;
//        }

        new AlertDialog.Builder(this)
                .setTitle("确定保存吗？")
                .setCancelable(false)
                .setNegativeButton("取消", ((dialog, which) ->
                        Toast.makeText(this, "取消保存", Toast.LENGTH_SHORT).show()))
                .setPositiveButton("确定", (dialog, which) -> {
                    //提交请求
                    RequestQueue queue = Volley.newRequestQueue(this);
                    String url = Config.url + "/hsmpy/smallWormBreedingMaterial/add";
                    StringRequest stringRequest = new StringRequest(Request.Method.POST, url,
                            new Response.Listener<String>() {
                                @Override
                                public void onResponse(String response) {
                                    //Toast.makeText(RepairTable.this, "保存成功", Toast.LENGTH_SHORT).show();
                                    Log.d("LB", response);
                                    try {
                                        JSONObject jsonObject = new JSONObject(response);
                                        String code = jsonObject.getString("code");
                                        if (code.startsWith("2"))
                                            Toast.makeText(SmallWormBreedingOutcoming.this,
                                                    "保存成功", Toast.LENGTH_SHORT).show();
                                        else
                                            Toast.makeText(SmallWormBreedingOutcoming.this,
                                                    "保存失败", Toast.LENGTH_SHORT).show();
                                    } catch (JSONException e) {
                                        e.printStackTrace();
                                    }
                                }
                            }, new Response.ErrorListener() {
                        @Override
                        public void onErrorResponse(VolleyError error) {
                            Toast.makeText(SmallWormBreedingOutcoming.this, "保存失败", Toast.LENGTH_SHORT).show();
                            Log.d("LB", error.toString());
                        }
                    }) {
                        @Override
                        protected Map<String, String> getParams() throws AuthFailureError {
                            Map<String, String> map=new HashMap<>();
//                            Double temp = Double.parseDouble(et_after_small_weight.getText().toString())+Double.parseDouble(et_box_weight.getText().toString());
                            map.put("id", idStr);
                            map.put("small_bug_breed_end_time", tv_end_date.getText().toString());
                            map.put("small_bug_breed_remarks", et_remarks.getText().toString());
                            map.put("small_bug_stop_reason",stop_reason);
                            map.put("factory",factory);
    //                        map.put("small_bug_breed_box_weight", et_box_weight.getText().toString());
    //                        map.put("after_small_weight", temp.toString());
    //                        map.put("big_bug_dregs_weight", middleWormAndWormDrossWeight.toString());
    //                        map.put("number", et_copies.getText().toString());
    //                        map.put("per_weight_kg", kgPerCopy.toString());
    //                        map.put("per_weight_g", gPerCopy.toString());
    //                        map.put("big_bug_dregs_weight", "0");
    //                        map.put("number", "0");
    //                        map.put("per_weight_kg", "0");
    //                        map.put("per_weight_g", "0");
    //                        map.put("start_number", et_first_box.getText().toString());
                            return map;
                        }
                    };
                    stringRequest.setRetryPolicy(new DefaultRetryPolicy(10 * 1000,
                            DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
                    queue.add(stringRequest);
                })
                .show();
    }

    public void getPrimaryKeyRecord(){
        RequestQueue queue = Volley.newRequestQueue(this);
        String url = Config.url + "/hsmpy/smallWormBreedingMaterial/getlist" + "?factory=" + factory;
        StringRequest stringRequest2 = new StringRequest(Request.Method.GET, url,
                new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {
                        try {
                            JSONObject jsonObject = new JSONObject(response);
                            if (!jsonObject.isNull("data")) {
                                JSONArray data = jsonObject.getJSONArray("data");
                                if( data.length()>0){
                                    for (int i=0; i < data.length(); i++){
                                        jsonObject = data.getJSONObject(i);
                                        primaryKeyList.add(jsonObject.getString("batch")+ "-" +jsonObject.getString("wormGroup")+"-"
                                                +jsonObject.getString("hatchBoxNumber")+"-"+jsonObject.getString("small_bug_breed_box_number"));
//                                        primaryKeyList.add(jsonObject.getString("batch")+ "-" +jsonObject.getString("wormGroup")+"-"
//                                                +jsonObject.getString("hatchBoxNumber"));
                                        idList.add(jsonObject.getString("id"));
                                    }
                                    ArrayAdapter<String> adapter = new ArrayAdapter<>(SmallWormBreedingOutcoming.this, android.R.layout.simple_spinner_item, primaryKeyList);
                                    sp_primary_key.setAdapter(adapter);
                                    sp_primary_key.setSelection(0,true);
                                    primaryKeyStr = primaryKeyList.get(0);
                                    idStr = idList.get(0);
                                    sp_primary_key.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                                        @Override
                                        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                                            primaryKeyStr = primaryKeyList.get(position);
                                            idStr = idList.get(position-1); //主鍵列表開頭多了一個空值，這裏對應減掉
                                            Toast.makeText(SmallWormBreedingOutcoming.this, primaryKeyStr, Toast.LENGTH_SHORT).show();
                                        }

                                        @Override
                                        public void onNothingSelected(AdapterView<?> parent) {

                                        }
                                    });
                                }else {
                                    Toast.makeText(SmallWormBreedingOutcoming.this, "沒有可操作的數據", Toast.LENGTH_SHORT).show();
                                }
                            }
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                Toast.makeText(SmallWormBreedingOutcoming.this,
                        "获取信息失败 " + error.getMessage(), Toast.LENGTH_SHORT).show();
            }
        });
        stringRequest2.setRetryPolicy(new DefaultRetryPolicy(10 * 1000,
                DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
        queue.add(stringRequest2);
    }

//    public void getPrimaryKeyRecord(){
//        RequestQueue queue = Volley.newRequestQueue(this);
//        String url = Config.url + "/hsmpy/smallWormBreedingMaterial/getlist";
//        StringRequest stringRequest2 = new StringRequest(Request.Method.GET, url,
//                new Response.Listener<String>() {
//                    @Override
//                    public void onResponse(String response) {
//                        try {
//                            JSONObject jsonObject = new JSONObject(response);
//                            if (!jsonObject.isNull("data")) {
//                                JSONArray data = jsonObject.getJSONArray("data");
//                                if( data.length()>0){
//                                    for (int i=0; i < data.length(); i++){
//                                        jsonObject = data.getJSONObject(i);
//                                        primaryKeyList.add(jsonObject.getString("batch")+ "/" +jsonObject.getString("wormGroup")+"/"
//                                                +jsonObject.getString("hatchBoxNumber"));
//                                        idList.add(jsonObject.getString("id"));
//                                        weightList.add(jsonObject.getString("smallBugBreedBoxWeight"));
//                                        Log.d("weight", weightList.toString());
//                                    }
//                                    ArrayAdapter<String> adapter = new ArrayAdapter<>(SmallWormBreedingOutcoming.this, android.R.layout.simple_spinner_item, primaryKeyList);
//                                    sp_primary_key.setAdapter(adapter);
//                                    sp_primary_key.setSelection(0,true);
//                                    primaryKeyStr = primaryKeyList.get(0);
//                                    idStr = idList.get(0);
//                                    et_after_small_weight.setText(weightList.get(0));
//                                    sp_primary_key.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
//                                        @Override
//                                        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
//                                            primaryKeyStr = primaryKeyList.get(position);
//                                            idStr = idList.get(position-1); //主鍵列表開頭多了一個空值，這裏對應減掉
//                                            et_after_small_weight.setText(weightList.get(position-1));
//                                            Log.d("primaryKeyList", weightList.get(position-1));
//                                            Toast.makeText(SmallWormBreedingOutcoming.this, primaryKeyStr, Toast.LENGTH_SHORT).show();
//                                        }
//
//                                        @Override
//                                        public void onNothingSelected(AdapterView<?> parent) {
//
//                                        }
//                                    });
//                                }else {
//                                    Toast.makeText(SmallWormBreedingOutcoming.this, "沒有可操作的數據", Toast.LENGTH_SHORT).show();
//                                }
//                            }
//                        } catch (JSONException e) {
//                            e.printStackTrace();
//                        }
//                    }
//                }, new Response.ErrorListener() {
//            @Override
//            public void onErrorResponse(VolleyError error) {
//                Toast.makeText(SmallWormBreedingOutcoming.this,
//                        "获取信息失败 " + error.getMessage(), Toast.LENGTH_SHORT).show();
//            }
//        });
//        stringRequest2.setRetryPolicy(new DefaultRetryPolicy(10 * 1000,
//                DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
//        queue.add(stringRequest2);
//    }

    /**
     * 日期选择
     * @param activity
     * @param themeResId
     * @param tv
     * @param calendar
     */
    public static void showDatePickerDialog(Activity activity, int themeResId, final TextView tv, Calendar calendar) {
        // 直接创建一个DatePickerDialog对话框实例，并将它显示出来
        new DatePickerDialog(activity, themeResId, new DatePickerDialog.OnDateSetListener() {
            // 绑定监听器(How the parent is notified that the date is set.)
            @Override
            public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                // 此处得到选择的时间，可以进行你想要的操作
                tv.setText(year + "-" + (monthOfYear + 1) + "-" + dayOfMonth);
            }
        }
                // 设置初始日期
                , calendar.get(Calendar.YEAR)
                , calendar.get(Calendar.MONTH)
                , calendar.get(Calendar.DAY_OF_MONTH)).show();
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        String weight = data.getStringExtra("weight");
        switch (activeButton){
            case "get_box_weight":
                et_box_weight.setText(weight);
                break;
            default:
                break;
        }
    }
    public void goWeight(View view) {
        switch (view.getId()) {
            case R.id.btn_get_box_weight:
                activeButton = "btn_get_box_weight";
                break;
            default:
                break;
        }
        Intent intent = new Intent(SmallWormBreedingOutcoming.this, WeightActivity.class);
        startActivityForResult(intent, 1);
    }

    public void saveNormal(RadioButton normal_rb, RadioButton abnormal_rb, RadioGroup rb) {
        final EditText temp_stop_reason = new EditText(this);
        temp_stop_reason.setHint("  如：是否给项目使用或者培育料出现异常");
        new AlertDialog.Builder(this)
                .setTitle("请填写终止原因？")
                .setView(temp_stop_reason)
                .setCancelable(false)
                .setNegativeButton("取消", ((dialog, which) ->{
                    Toast.makeText(this, "取消保存", Toast.LENGTH_SHORT).show();
                    rb.clearCheck();
                }
                ))
                .setPositiveButton("确定", (dialog, which) ->{
                    //设置终止原因
                    stop_reason=temp_stop_reason.getText().toString();
                    stop_flag=1;
                    normal_rb.setClickable(false);
                    abnormal_rb.setClickable(false);
                    Toast.makeText(SmallWormBreedingOutcoming.this,
                            "终止培育", Toast.LENGTH_SHORT).show();
                })
                .show();

    }

    public void saveAbnormal(RadioButton normal_rb, RadioButton abnormal_rb, RadioGroup rb) {
        new AlertDialog.Builder(this)
                .setTitle("要继续培育吗？")
                .setCancelable(false)
                .setNegativeButton("取消", ((dialog, which) ->{
                    Toast.makeText(this, "取消保存", Toast.LENGTH_SHORT).show();
                    rb.clearCheck();
                }))
                .setPositiveButton("确定", (dialog, which) ->{
                    stop_flag=1;
                    //设置终止原因
                    stop_reason="";
                    normal_rb.setClickable(false);
                    abnormal_rb.setClickable(false);
                    Toast.makeText(this, "继续培育", Toast.LENGTH_SHORT).show();
                })
                .show();
    }
}